<template>
  <el-card>
    <!-- 面包屑 -->
    <my-bread leavel1="权限管理"
              leavel2="权限列表"></my-bread>
    <!-- 表格 -->
    <el-table :data="Permissionlist"
              class="mar"
              height="400px"
              border
              style="width: 100%">
      <el-table-column type="index"
                       label="#"
                       width="180">
      </el-table-column>
      <el-table-column prop="pername"
                       label="权限名称"
                       width="180">
      </el-table-column>
      <el-table-column prop="perpath"
                       label="路径">
      </el-table-column>
      <el-table-column prop="perleavel"
                       label="层级">
        <template slot-scope="scope">
          <span v-if="scope.row.perleavel=='0'">一级</span>
          <span v-if="scope.row.perleavel=='1'">二级</span>
          <span v-if="scope.row.perleavel=='2'">三级</span>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      Permissionlist: [],
    };
  },
  created() {
    this.getPermissionlist();
  },
  methods: {
    async getPermissionlist() {
      // 在请求头中,提供token令牌
      //   const AUTH_TOKEN = localStorage.getItem('token');
      //   this.$http.defaults.headers.common['Authorization'] = AUTH_TOKEN;
      const res = await this.$http.get('/permissionlist');
      console.log(res);
      this.Permissionlist = res.data.permissionlist;
    },
  },
};
</script>

<style>
.mar {
  margin-top: 20px;
}
</style>